<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>发布流量任务</title>
        <link href="/static/Content/postingStyle/css/index.css" rel="stylesheet" type="text/css" media="all" />
        <script src="/static/Scripts/jquery-1.8.2.min.js"></script>
        <link href="/static/kindeditor/themes/default/default.css" rel="stylesheet" type="text/css" />
        <link href="/static/kindeditor/plugins/code/prettify.css" rel="stylesheet" type="text/css" />
        <script charset="utf-8" src="/static/kindeditor/kindeditor.js"></script>
        <script charset="utf-8" src="/static/kindeditor/lang/zh_CN.js"></script>
        <script charset="utf-8" src="/static/kindeditor/plugins/code/prettify.js"></script>
        <link href="/static/Content/showloading/showLoading.css" rel="stylesheet" type="text/css" />
        <script src="/static/Content/showloading/jquery.showLoading.js" type="text/javascript"></script>
        <script src="/static/Scripts/jquery.unobtrusive-ajax.min.js" type="text/javascript"></script>
        <script src="/static/Content/layer-v1.8.5/layer-v1.8.5/layer/layer.min.js"></script>
    </head>
    <body>
        <div id="post-main" class="post-main">
            <style type="text/css">
                #bulletin-top {display:block;}
                .J-zhaoshang{background:#cf203d;}
                .J-center{margin:0 auto;width:100%;min-width:990px;max-width:1200px;}
                .J-center img{width: 100%;}
                /* br */
                #br-bulletin-top {display:none}
                .J-br-banner {background-color:#04bb85}
                /* es */
                #es-bulletin-top {display:none}
                .J-es-banner {background-color:#d71843}
            </style>
            <style>
                .box_right{
                    width: 700px;
                    float: right;
                }
                .box_left{
                    margin: 15px;
                    width: 422px;
                    height: 422px;
                    display: block;
                    float: left;
                    overflow: hidden;
                    border: 1px solid #999;
                    background-color: #EEE;
                    position: relative;
                    border-radius: 3px;
                    background-size: 100%;
                    background-repeat: no-repeat;
                }
                .box_left input{
                    display: block;
                    width: 100%;
                    height: 100%;
                    overflow: hidden;
                    background-color: transparent;
                    border: 0;
                    text-indent: -200px;
                    font-size: 0;
                    cursor: pointer;
                    position: absolute;
                    z-index: 10;
                    left: 0;
                    top: 0;
                }
                .box_left input:hover {
                    background: rgba(0,0,0,0.1);
                }
                .box_left p{
                    display: block;
                    clear: both;
                    width: 100%;
                    height: 30px;
                    line-height: 30px;
                    overflow: hidden;
                    text-align: center;
                    font-size: 16px;
                    position: absolute;
                    z-index: 5;
                    left: 0px;
                    bottom: 50px;
                    color: #333;
                    text-indent: 0;
                }
                .box_left:hover p {
                    background-color: #333;
                    color: #FFF;
                }
                .box_left img{
                    width: 220px;
                    height: 220px;
                    position: absolute;
                    top: 0;
                    left: 0;
                    right: 0;
                    bottom: 0;
                    margin: auto;
                }
                #pt-BindSell{
                    max-width: 220px;
                }
                .package img {
                    max-width: 1154px;
                }
            </style>
            <div class="site-nav">
                <div class="grid-c" style="width: 1200px;">
                    <div class="welcome_info">
                        欢迎您！ {$Think.session.userinfo.name} |<a href=""><span> 修改密码 </span></a>| 
                        <!--<a target="_self" rel="nofollow" href="">站内信<span class="fb" id="my-messages"></span></a> |-->
                        <a href="{:U('Account/out')}" rel="nofollow">退出系统</a>
                    </div>
                    <ul class="top-nemu">
                        <li><a href=""><span>账号充值<img height="12" width="15" src="/static/Content/EasyStyle/images/icon_hot.gif"></span></a></li>



                        <li><a href=""><span><t>smt测评</t>教程</span></a></li>
                    </ul>
                </div>
            </div>
            <div class="header">
                <div class="seller-logo"><a href="/" title="Manufacturers" >My MliEasy</a></div>
                <div class="headswitch" id="headswitch" default="zh_CN">
                </div>
            </div>
            <div class="page" id="post-main-container">
                <form id="wholesale_product_form" name="wholesaleProductForm" method="post" enctype="multipart/form-data"
                      autocomplete="off">
                    <div id="steper" class="box module tab-content">
                        <div class="module-hd">
                            <h2>发布流量任务信息
                            </h2>
                            <!--                            <span><a
                                                                target="_blank" class="feedback-tip">查看发布任务规则</a></span>-->
                        </div>
                        <div id="pc" class="box-content">

                            <div id="productList" class="select-area">


                                <div class="post-wrap tab-content" id="post-warp">

                                    <div id="post-sku-alert" class="board-alert-large1" style="padding-top: 15px; padding-bottom: 15px;">
                                        <img src="{:sysconf('add_img')}"/>

                                    </div>
                                    <!--                                    <div class="module box">
                                                                            <div class="module-hd">
                                                                                <h2>发布任务
                                                                                </h2>
                                                                                <div style="float: right">
                                                                                    <span><a href="../seller/SellerDetail?sellerId=123" target="_blank" class="help-tip" id="help-index" tabindex="-1" rel="index">我要帮助</a></span>
                                                                                    <span style="margin-top: 4px;">
                                                                                        <select id="select-rule" disabled="disabled">
                                                                                            <option value="">普通任务</option>
                                                                                            <option value="">知识产权规则</option>
                                                                                            <option value="">品牌列表参考</option>
                                                                                            <option value="">搜索作弊规则解析</option>
                                                                                            <option value="">禁限售商品目录</option>
                                                                                        </select>
                                                                                    </span>
                                                                                </div>
                                                                            </div>
                                    
                                                                        </div>-->


                                    <div class="module">
                                        <div class="module-hd">
                                            <h2>1. 任务基本信息区</h2>
                                        </div>
                                        <div class="box_left" id="showImg">
                                            <input type="file" name="img" id="selectImg"/>
                                            <img src="/static/images/upload.png"/>
                                            <p>请选择商品主图</p>
                                        </div>
                                        <div class="box_right">
                                            <div id="div_shopkeeperName" class="module-content">
                                                <label class="module-name">
                                                    <a name="product-title">&nbsp;</a><span class="required">店铺名称：</span></label>
                                                <select id="pt-BindSell">
                                                    {volist name='store' id='vo'}
                                                    <option value="{$vo.id}">{$vo.name}</option>
                                                    {/volist}
                                                </select>
                                                <span class="module-tip" id="pt-shopkeeperNames" style="">请选择您的店铺名称，确保接手人搜索到您的店铺。<a href="{:U('Task/index')}?showTab=3">绑定店铺名称</a> </span><a
                                                    rel="title" title='您的“店铺ID”或者“掌柜名称”' class="help-tip" tabindex="-1" href="javascript:void(0);">掌柜名称帮助</a>
                                            </div>
                                            <div class="module-error" name="pt-err-tips">
                                                <p id="pt-err-tips" style="display: none;" class="err-tip msg-err">
                                                    请输入商品标题信息(不能包含中文字符)。
                                                </p>
                                            </div>
                                            <div id="pt" class="module-content">
                                                <label class="module-name">
                                                    <a name="product-title">&nbsp;</a><span class="required">搜索关键词：</span></label>
                                                <input type="text" name="pt-url" id="pt-urlAliExpress" class="ipt-item" style="width: 270px;padding-left:3px;"/>
                                                <span class="module-tip" id="pt-tips" style="">多关键词可以用“，”分割
                                                    <a rel="title" title='搜索关键词' class="help-tip" tabindex="-1" href="javascript:void(0);">搜索关键词</a>
                                            </div>
                                            <div class="module-error" name="pt-err-tips">
                                                <p id="purl-err-tipsAliExpress" style="display: none;" class="err-tip msg-err">
                                                    请输入搜索关键词。
                                                </p>
                                            </div>


                                            <div class="module-content">
                                                <label class="module-name">
                                                    <span class="required">商品价格：</span>
                                                </label>
                                                <div class="module-body">
                                                    <input id="guaranteePrice" name="guaranteePrice" type="text" maxlength="8" size="8" style="padding-left:3px;"/>美元
                                                    <span class="module-tip" id="pt-tips" style="">请正确填写商品的展示价格,如 US $17.94 - 19.99  填17.94</span>
                                                    <a rel="title" title='商品单价' class="help-tip" tabindex="-1" href="javascript:void(0);">商品价格</a>
                                                </div>
                                            </div>
                                            <div class="module-error">
                                                <p id="spu-price-error" class="err-tip msg-err" style="display: none;">
                                                    请输入0.01~100000之间的金额
                                                </p>
                                            </div>
                                            <div class="module-error" name="pk-err-tips">
                                                <p id="pk-err-tips" class="err-tip msg-err" style="display: none;">
                                                    商品关键词信息错误,至少填写一组关键词(不能包含中文字符)。
                                                </p>
                                            </div>
                                            <div class="module-content clearfix">
                                                <label class="module-name"><a name="product-property">&nbsp;</a>选择套餐：</label>
                                                <div class="module-body">
                                                    <p class="post-tip">
                                                        <select id="DataPlanList">
                                                            {volist name='package' id='vo'}
                                                            <option value="{$vo.id}">{$vo.name}</option>
                                                            {/volist}
                                                        </select>
                                                    </p>
                                                    <div class="post-property" id="post-property">
                                                        <table class="sys-attr" id="sys-attr">
                                                        </table>
                                                        <div id="purlAliExpress" class="module-content" style="width: auto;">
                                                            {volist name='package' id='vo'}
                                                            <div  id="DataPlan_{$vo.id}" class="DataPlanDiv">
                                                                {$vo.description|htmlspecialchars_decode}
                                                            </div>
                                                            {/volist}
                                                        </div>
                                                    </div>
                                                    <style>
                                                        .submit-btn{
                                                            box-shadow: none;
                                                            background: #f18d05;
                                                            color: white;
                                                            text-shadow: none;
                                                            border: none;
                                                            height: 27.6px;
                                                            font-size: 12px;
                                                            line-height: 27.6px;
                                                            padding: 0px 20.48px;
                                                            margin: 0;
                                                            text-decoration: none;
                                                            text-align: center;
                                                            cursor: pointer;
                                                            width: 120px;
                                                        }
                                                    </style>
                                                    <button type="button" class="submit-btn" id="btn-submit" onclick="ProductPost()" style="margin-top:10px;">提交</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="module">
                                        <div class="module-hd">
                                            <h2>2. 产品详细描述</h2>
                                        </div>
                                        <div class="module-content clearfix">
                                            <div id="notice-container" class="package">
                                                {:htmlspecialchars_decode(sysconf('package'))}
                                            </div>
                                        </div>
                                    </div>
                                    <!--                                    <div class="board-tip-simple post-ask-center">
                                                                            感觉使用不方便？&nbsp;<a target="_blank" href="/message/research">我要提意见或建议！</a>
                                                                        </div>-->
                                </div>

                            </div>
                        </div>
                    </div>
                    <div class="post-help" id="h">
                        <h2>帮助信息</h2>
                        <a href="#close-help" id="post-help-close" title='关闭'>关闭</a>
                    </div>
                </form>
            </div>
    </body>
</html>

<script type="text/javascript">


    var zss = new RegExp("^[0-9]+(.[0-9]{1,3})?$");   //验证有1-3位小数的正实数
    var yzhz = /[\u4e00-\u9fa5]+/i;   //验证汉字
    var reg = new RegExp("^[0-9]*$");   //验证整数

    $(function() {
        if ("{:count($store)}" == 0) {
            layer.alert("请先设置店铺名称", 0, function() {
                location.replace("{:U('Task/index')}?showTab=3")
            })
        }
        if ("{:count($package)}" == 0) {
            layer.alert("暂无可选套餐", 0, function() {
                location.replace("{:U('Task/index')}")
            })
        }
        DataPlanListChange();
        $("#DataPlanList").change(function() {
            DataPlanListChange();
        })

        //商品链接
        $("#pt-urlAliExpress").change(function() {
            var pt_urlAliExpress = $("#pt-urlAliExpress").val();
            if (pt_urlAliExpress.length <= 0) {
                $("#purl-err-tipsAliExpress").css("display", "block");
                Validate = 0;
            } else {
                $("#purl-err-tipsAliExpress").css("display", "none");
            }
        })

        //担保价格
        $("#guaranteePrice").change(function() {
            var guaranteePrice = $("#guaranteePrice").val();
            if (!guaranteePrice || !zss.test(guaranteePrice)) {
                $("#spu-price-error").css("display", "block");
                $("#spu-price-error").text(" 请输入0.01~100000之间的金额")
                Validate = 0;

            } else {
                $("#spu-price-error").css("display", "none");

            }
        })

    })


    //选择套餐
    function DataPlanListChange() {
        var selected = $("#DataPlanList option:selected").val();
        $(".DataPlanDiv").hide();
        $("#DataPlan_" + selected).show();
    }




    //提交
    function ProductPost() {
        var store = $('#pt-BindSell option:selected').val();
        var package = $("#DataPlanList option:selected").val();     //套餐
        var keywords = $("#pt-urlAliExpress").val();       //搜索关键词
        var price = $('#guaranteePrice').val();
        var Validate = 1;
        //搜索关键词
        if (keywords.length <= 0) {
            $("#purl-err-tipsAliExpress").css("display", "block");
            Validate = 0;
        } else {
            $("#purl-err-tipsAliExpress").css("display", "none");
        }
        var files = $('#selectImg').prop('files');
        console.log(files.length);
        if (files.length == 0) {
            layer.alert('请上传商品主图！');
            return false;
        }
        var data_obj = new FormData();
        data_obj.append('store', store);
        data_obj.append('package', package);
        data_obj.append('keywords', keywords);
        data_obj.append('price', price);
        data_obj.append('img', files[0]);
        //提交
        if (Validate == 1) {
            $.ajax({
                url: "__SELF__",
                type: "post",
                dataType: "json",
                data: data_obj,
                cache: false,
                contentType: false,
                processData: false,
                success: function(data) {
                    if (data.status == 1) {
                        //清除数据
                        layer.alert(data.info, 1, function() {
                            location.reload();
                        });
                    } else {
                        layer.alert(data.info, 0);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    layer.msg("出错啦!请重试", 3, 8);
                }
            })
        } else {
            layer.alert('请修改红色错误提示位置!', 0);
        }
    }
</script>
<script>
    /*定义全局变量存贮图片信息*/
    var base64head = "";

    function headPortraitListener(e) {
        var img = document.getElementById('showImg');
        if (window.FileReader) {
            var file = e.target.files[0];
            var reader = new FileReader();
            if (file && file.type.match('image.*')) {
                reader.readAsDataURL(file);
            } else {
                img.css('display', 'none');
                img.attr('src', '');
            }
            reader.onloadend = function(e) {
                img.setAttribute('src', reader.result);
                img.style = "background-image:url(" + reader.result + ")";
                $('#showImg img,#showImg p').hide();
                base64head = reader.result;
            }
        }
    }
    $(function() {
        $("#selectImg").on("change", headPortraitListener);
    });
</script>

